/**
 * An Feed Entity.
 * @author William
 * 2012-1-14
 */
package com.ytu.irss;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RSSFeed {
	
	private String title = null;
	private String pubDate = null;
	private int itemCount = 0;
	private List<RSSItem> itemList;
	
	
	public RSSFeed(){
		itemList = new ArrayList<RSSItem>();
	}
	
	public int addItem(RSSItem item){
		itemList.add(item);
		itemCount++;
		return itemCount;
	}
	
	public RSSItem getItem(int location){
		return itemList.get(location);
	}
	
	@SuppressWarnings("rawtypes")
	public List getAllItems(){
		return itemList;
	}
	
	@SuppressWarnings("rawtypes")
	public List getAllItemsForListView(){
		List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();
		int size = itemList.size();
		for(int i = 0;i<size;i++){
			HashMap<String,Object> item = new HashMap<String,Object>();
			item.put(RSSItem.TITLE, itemList.get(i).getTitle());
			item.put(RSSItem.PUBDATE, itemList.get(i).getPubDate());
			data.add(item);
		}
		return data;
	}
	
	public int getItemCount(){
		return itemCount;
	}

	public String getPubDate() {
		return pubDate;
	}
	
	public void setPubDate(String pubDate) {
		this.pubDate = pubDate;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	

}
